package com.seguriapp.adapters;

import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.seguriapp.R;
import com.seguriapp.entities.EntityType;

/**
 * TODO(pjohnson): Insert description
 * 
 * @author Pablo Johnson (pablo.88j@gmail.com)
 */
public class LstTypeEntityAdapter extends BaseAdapter {

	private Context mContext;
	private int mLayout;
	private List<EntityType> mLstEntity;

	public LstTypeEntityAdapter(final Context context, final int layout,
			final List<EntityType> entityList) {
		mContext = context;
		mLayout = layout;
		mLstEntity = entityList;
	}

	@Override
	public int getCount() {
		return mLstEntity.size();
	}

	@Override
	public Object getItem(int index) {
		return mLstEntity.get(index);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(final int position, View convertView,
			final ViewGroup parent) {
		final EntityType crime = mLstEntity.get(position);

		if (convertView == null) {
			convertView = (RelativeLayout) View
					.inflate(mContext, mLayout, null);
		}

		final TextView twTitle = (TextView) convertView
				.findViewById(R.id.entity_title);
		twTitle.setText(crime.getName());

		return convertView;
	}
}
